package com.example.assignment01_javaee.Service.Impl;

import com.example.assignment01_javaee.Entity.Product;
import com.example.assignment01_javaee.Dao.ProductDao;
import com.example.assignment01_javaee.Service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao productDao;

    //查询所有的product
    @Override
    public List<Product> getAllProducts(){
        return productDao.getAllProducts();
    }

    //根据product id查找
    @Override
    public Product getProductById(int productId){
        return productDao.getProductById(productId);
    }

    //增加product
    @Override
    public void createProduct(Product product){
        productDao.createProduct(product);
    }

    //更改product数据
    @Override
    public void updateProduct(Product product){
        productDao.updateProduct(product);
    }

    //根据product id删除
    @Override
    public void deleteProduct(int productId){
        productDao.deleteProduct(productId);
    }
}
